﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;

public partial class WebUserControl_DanhsachtoanTVV : System.Web.UI.UserControl
{ 
    ClassExecute.ClassExecute dt;
    string str = BCDataCenter.Configuration.CurrentConnectionString;
    static string error = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindToDrop();
        }
    }
    void BindToDrop()
    {
        dt = new ClassExecute.ClassExecute();
        DataTable db = dt.Get_Data_DataTable(str, ref error, "GET_SITENAME_ALL", CommandType.StoredProcedure);
        DropDownList1.DataSource = db;
        DropDownList1.DataTextField = "sitename";
        DropDownList1.DataValueField = "Sitecode";
        DropDownList1.DataBind();
    }
    protected void bt_baocao_Click(object sender, EventArgs e)
    {
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        using (MemoryStream filestream = new MemoryStream())
        {
            string contentType = "application/ms-excel";
            string fileName = DateTime.Now.ToString() + "_BaoCaoToanBoTVV.xls";
            ASPxPivotGridExporter1.ExportToXls(filestream);
            byte[] buffer = filestream.GetBuffer();
            Response.Clear();
            Response.Buffer = false;
            Response.AppendHeader("Content-Type", contentType);
            Response.AppendHeader("Content-Transfer-Encoding", "binary");
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
            Response.BinaryWrite(buffer);
            Response.End();
        }
    }
}
